<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>职位收藏</title>
      <link rel="stylesheet" type="text/css" href="../css/api.css"/>
      <link rel="stylesheet" type="text/css" href="../css/style.css"/>
      <style>
          .job{width: 100%;}
          .list{padding: 53px 20px 20px;}
          .wrap{justify-content: space-between;align-items: center;padding-bottom: 30px}
          .left{justify-content: space-around;margin-right: 5px}
          .left .title{font-size: 16px;color: #000}
          .left .desc{align-items: center;margin-top: 6px;justify-content: flex-start;}
          .left .desc .money{color: #EB5758;margin-right: 10px;flex-shrink: 0}
          .left .desc .money span.font{font-size: 24px}
          .left .desc .type{flex-shrink: 0;}
          .left .desc .type span{padding: 3px 7px;color: #8B8EA3;font-size: 11px;background-color: #E4E7F0;border-radius: 5px}
          .left .desc .type span.marR{margin-right: 5px}
          .right{flex-shrink: 0}
          .right span{padding:7px 17px;color: #000;font-size: 13px;border: 1px solid #000;border-radius: 16px}
      </style>
  </head>
  <body>
    <div class="job">
      <div class="returnBox">
        <div class="return"> <img src="../image/return.png" onclick="api.closeWin()"> <span class="us">我的收藏</span></div>

      </div>
      <div class="list">
        <!-- <div class="wrap flex-wrap">
          <div class="left flex-wrap flex-vertical">
            <div class="title line1">全新网络在线高薪兼职，简单立及上岗</div>
            <div class="desc flex-wrap ">
              <div class="money"><span class="font">800 </span>元/天</div>
              <div class="type">
                <span class="marR">长期</span>
                <span class="marR">日结</span>
                <span>男女不限</span>
              </div>
            </div>
          </div>
          <div class="right">
            <span class="collect">取消收藏</span>
          </div>
        </div> -->

      </div>
    </div>
  </body>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/encrypt.js"></script>
  <script type="text/javascript">

      apiready = function(){
        $api.fixStatusBar($api.dom('.job'));
        var base = new Base64();
        var userid = $api.getStorage('userID');
        refersh()

        init(1)
        var b = 0
        var pi = 1
        var arryHtml = []
        function init(pi){
          var pz = 20
          var json = {'userID':userid,'pi':pi,'pz':pz}
          var parameter = base.encode(JSON.stringify(json));
          var signValue = parameter + secretKey
          var sign = signValue.MD5(32)

          $api.post(url+'getJianzhiBookmarkByUser.ashx', {values:{parameter:parameter,sign:sign}}, function(ret){

            // alert($api.jsonToStr(ret))
            if(ret.code == 200){

              var html = '';
              var data = ret.data.JobList;

              b = data.length
              if(!data.length){
                b = 0
              }
              if(b > 0){
                arryHtml = arryHtml.concat(data)
                for (var i = 0; i < arryHtml.length; i++) {
                  html+='<div class="wrap flex-wrap" >'+
                  '<div class="left flex-wrap flex-vertical" data-id="'+arryHtml[i].jianZhiID+'">'+
                  '<div class="title line1">'+arryHtml[i].listTitle+'</div>'+
                  '<div class="desc flex-wrap ">'+
                  '<div class="money"><span class="font">'+arryHtml[i].salary+' </span>'

                  if(arryHtml[i].salaryUnit == 10){ //薪水单位
                    html+='元/小时</div>'
                  }else if(arryHtml[i].salaryUnit == 20){
                    html+='元/天</div>'
                  }else if(arryHtml[i].salaryUnit == 30){
                    html+='元/次</div>'
                  }

                  html+='<div class="type">'
                  if(arryHtml[i].effective == 10){ //有效时间
                    html+='<span class="marR">长期</span>'
                  }

                  if(arryHtml[i].paymentTerms == 10){ //结算方式
                    html+='<span class="marR">日结</span>'
                  }else if(arryHtml[i].paymentTerms == 20){
                    html+='<span class="marR">周结</span>'
                  }else if(arryHtml[i].paymentTerms == 30){
                    html+='<span class="marR">月结</span>'
                  }

                  if(arryHtml[i].sex == 10){ //性别要求
                    html+='<span >仅限男</span>'
                  }else if(arryHtml[i].sex == 20){
                    html+='<span >仅限女</span>'

                  }else if(arryHtml[i].sex == 30){
                    html+='<span >男女不限</span>'
                  }

                  html+='</div>'+
                  '</div>'+
                  '</div>'+
                  '<div class="right" data-mark="'+arryHtml[i].bookmarkID+'">'+
                  '<span class="collect">取消收藏</span>'+
                  '</div>'+
                  '</div>'
                }
              }


                $api.html($api.dom('.list'), html);

                var wrapList = $api.domAll('.left');
                for (var i = 0; i < wrapList.length; i++) {
                  $api.addEvt(wrapList[i], 'click', function(){
                    var jianZhiID = $api.attr(this,'data-id')
                    api.openWin({
                      name: 'jobDetails',
                      url: './jobDetails.html',
                      pageParam:{
                        jianZhiID:jianZhiID
                      }
                    });

                  });
                }

                var wrapList = $api.domAll('.right');
                for (var i = 0; i < wrapList.length; i++) {
                  $api.addEvt(wrapList[i], 'click', function(){
                    var bookmarkID = $api.attr(this,'data-mark');

                    var jsons = {'userID':userid,'bookmarkID':bookmarkID};
                    var parameters = base.encode(JSON.stringify(jsons));
                    var signValues = parameters + secretKey;
                    var signs = signValues.MD5(32);

                    $api.post(url+'cancelJianzhiBookmark.ashx', {values:{parameter:parameters,sign:signs}}, function(ret){

                      if(ret.code == 200){
                        api.toast({
                          msg: ret.msg,
                          duration: 2000,
                          location: 'middle'
                        });
                        window.location.reload()
                      }else{
                        api.toast({
                          msg: ret.msg,
                          duration: 2000,
                          location: 'middle'
                        });
                      }
                    })

                  });
                }
              }else{
                api.toast({
                  msg: ret.msg,
                  duration: 2000,
                  location: 'middle'
                });
              }
            })

        }
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:20           //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){

          if (b <20 ) {
                $api.append($api.dom('.list'),'<div class="nomore">没有更多了~</div>')
                api.removeEventListener({
                    name: 'scrolltobottom'
                });
            } else {
                pi+=1;
                init(pi)
            }
        });

      };
  </script>
  </html>
